package database

import (
	"fmt"
	"github.com/redis/go-redis/v9"
	"time"
)

func NewRedisDB(host, username, pass string, port, db int) *redis.Client {
	redisDb := redis.NewClient(&redis.Options{
		Addr:         fmt.Sprintf("%s:%d", host, port),
		Username:     username,
		Password:     pass,
		DB:           db,
		PoolSize:     100, // 连接池大小
		ReadTimeout:  5 * time.Second,
		WriteTimeout: 5 * time.Second,
	})
	return redisDb
}
